package io.renren.modules.task.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.annotation.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.task.entity.MtCcAreaRouteEntity;
import io.renren.modules.task.service.MtCcAreaRouteService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;


/**
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-23 09:03:45
 */
@RestController
@RequestMapping("generator/mtccarearoute")
public class MtCcAreaRouteController {
    @Autowired
    private MtCcAreaRouteService mtCcAreaRouteService;

    /**
     * 列表
     */
    @SysLog("获取Agv线路列表")
    @RequestMapping("/list")
    @RequiresPermissions("generator:mtccarearoute:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = mtCcAreaRouteService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @SysLog("依据Id获取Agv线路")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:mtccarearoute:info")
    public R info(@PathVariable("id") Integer id) {
        MtCcAreaRouteEntity mtCcAreaRoute = mtCcAreaRouteService.getById(id);

        return R.ok().put("mtCcAreaRoute", mtCcAreaRoute);
    }

    /**
     * 保存
     */
    @SysLog("保存Agv线路")
    @RequestMapping("/save")
    @RequiresPermissions("generator:mtccarearoute:save")
    public R save(@RequestBody MtCcAreaRouteEntity mtCcAreaRoute) {
        mtCcAreaRouteService.save(mtCcAreaRoute);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("修改Agv线路")
    @RequestMapping("/update")
    @RequiresPermissions("generator:mtccarearoute:update")
    public R update(@RequestBody MtCcAreaRouteEntity mtCcAreaRoute) {
        mtCcAreaRouteService.updateById(mtCcAreaRoute);

        return R.ok();
    }

    /**
     * 删除
     */
    @SysLog("删除Agv线路")
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mtccarearoute:delete")
    public R delete(@RequestBody Integer[] ids) {
        mtCcAreaRouteService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
